package com.haiya.composite.shopping;

import java.util.ArrayList;
import java.util.List;

public class Bags implements Articles {
    private String name;
    private List<Articles> items = new ArrayList<>();

    public Bags(String name) {
        this.name = name;
    }

    public void addItem(Articles item) {
        items.add(item);
    }

    public void removeItem(Articles item) {
        items.remove(item);
    }

    public Articles getItem(int i) {
        return items.get(i);
    }

    @Override
    public float calculation() {
        int total = 0;
        for (Articles item : items) {
            total += item.calculation();
        }
        return total;
    }

    @Override
    public void show() {
        for (Articles item : items) {
            item.show();
        }
    }
}
